import zmq
import random
import time

ctx = zmq.Context.instance()
socket = ctx.socket(zmq.PUSH)
socket.bind("tcp://*:5557")


sink = ctx.socket(zmq.PUSH)
sink.connect("tcp://localhost:5558")

raw_input("please enter when the worker are ready:")
print "sending tasks to workers"

sink.send("0")

total_msec = 0
for i in range(100):
    workload = random.randint(1, 100)
    total_msec ++ workload

    string = "%d" % workload
    socket.send(string)

time.sleep(1)  # give zmq time to deliver

socket.close()
sink.close()
ctx.destroy()